package actions;

import java.sql.SQLException;
import java.util.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.RowSet;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import db.DbException;
import forms.AdmitStatusChangeForm;
import model.AdminModel;
import model.ReviewerModel;

public class ReviewerDecisionAction extends Action {

	private static final boolean DEBUG = true;

	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws DbException {
				
		// get status change we want from the form
		AdmitStatusChangeForm aform = (AdmitStatusChangeForm)form;
		String updatedStatus = aform.getUpdatedStatus();
		
		if (DEBUG) {
			System.err.println("ReviewerDecisionAction: updatedStatus(" + updatedStatus +")");
		}

		String first = (String)request.getSession().getAttribute("fname");
		String middle = (String)request.getSession().getAttribute("mname");
		String last = (String)request.getSession().getAttribute("lname");
		
		int user_id = ReviewerModel.getApplicationId(first, middle, last);
		AdminModel.updateApplicationStatus(user_id, updatedStatus);
				
		return mapping.findForward("success");
	}
}